package com.altfee.example.drawable;

import android.app.Activity;
import android.content.res.Resources;
import android.graphics.drawable.TransitionDrawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

import com.altfee.example.R;

public class DrawableActivity extends Activity {
	LinearLayout mLinearLayout;

	protected void onCreate(Bundle savedInstanceState) {
		// http://ysongren.blog.163.com/blog/static/61542207201010414535730/
		super.onCreate(savedInstanceState);
		mLinearLayout = new LinearLayout(this);
		ImageView i = new ImageView(this);
		i.setAdjustViewBounds(true);
		i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT));
		mLinearLayout.addView(i);
		setContentView(mLinearLayout);
		Resources res = getResources();
		TransitionDrawable transition = (TransitionDrawable)res.getDrawable(R.drawable.expand_collapse);
		i.setImageDrawable(transition);
		transition.startTransition(10000);
	}
	
	/*public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.harddrawable);
	}*/
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		menu.add(0, 0, 0, "SimpleDrawable");
		return super.onCreateOptionsMenu(menu);
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch(item.getItemId()){
		case 0:
			setContentView(new SimpleDrawableView(this));
			break;
		}
		return super.onOptionsItemSelected(item);
	}
}
